﻿using CommandLine;
using CommandLine.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TfsGetBuildDrop.ConsoleApp
{
    class Options
    {
        /// <summary>
        /// Command line parameter for the address of TFS server collection
        /// </summary>
        [Option('a',"address", Required = true , HelpText = "Tfs web address.")]
        public string Address { get; set; }

        /// <summary>
        /// Command line parameter for the Project name
        /// </summary>
        [Option('j', "project", Required = true, HelpText = "Tfs project name.")]
        public string Project { get; set; }

        /// <summary>
        /// Command line parameter for the buil name
        /// </summary>
        [Option('b', "buil", Required = true, HelpText = "Tfs build number.")]
        public string BuildNumber { get; set; }

        /// <summary>
        /// Command line parameter for open by internet browser
        /// </summary>
        [Option('w', "browser", Required = false, HelpText = "Open with browser.")]
        public bool Browser { get; set; }

        /// <summary>
        /// Command line parameter for Username (if empty use the current windows user)
        /// </summary>
        [Option('u', "Username", Required = false, HelpText = "Username.")]
        public string Username { get; set; }

        /// <summary>
        /// Command line parameter for password
        /// </summary>
        [Option('p', "Password", Required = false, HelpText = "Password.")]
        public string Password { get; set; }

        /// <summary>
        /// Command line parameter for file zip name
        /// </summary>
        [Option('f', "file", Required = false, HelpText = "Filename.")]
        public string FileName { get; set; }

        /// <summary>
        /// Command line parameter for file zip name
        /// </summary>
        [Option('d', "decompress", Required = false, HelpText = "Decompress to directory.")]
        public string DecompresDir { get; set; }

        /// <summary>
        /// Command line usage help
        /// </summary>
        /// <returns></returns>
        [HelpOption]
        public string GetUsage()
        {
            var usage = new StringBuilder();
            usage.AppendLine(HelpText.AutoBuild(this, (HelpText current) => HelpText.DefaultParsingErrorsHandler(this, current)));
            usage.AppendLine(@"Example usage: ");
            usage.AppendLine(@"");
               usage.AppendLine(@"TfsGetBuildDrop -a http://tfs.domain.it:8080/tfs/DefaultCollection -j ProjectName -b BuilName -f c:\file.zip");
            
            return usage.ToString();
        }
    }
}
